



$(document).ready(function(){
	var id=getvl("id");
	findUserDetail(id);
	
});


/**
 * 获取会员详情
 */
function findUserDetail(id){
  		$.ajax({
				url: urlcore + "/api/muser/findUserDetail?id="+id,
				type: "get",
				dataType: 'json',
				contentType: "application/json;charset=utf-8",
				success:function(data){
					var da=data.data;
					if(da.address.addressDetail==null){
						var address=da.address.province+da.address.city+da.address.area;
					}else{
						var address=da.address.province+da.address.city+da.address.area+da.address.addressDetail;
					}
					
					$("#nickName").html(da.account.muser.userName);
					$("#phone").html(da.account.muser.phone);
					$("#idCard").html(da.account.muser.idCard==null?"无":da.account.muser.idCard);
					$("#duobi").html(da.account.duoBi);
					$("#yabi").html(da.account.yaBi);
					$("#totalMoney").html("￥"+da.account.totalMoney);
					$("#income").html("￥"+da.account.income);
					$("#machineCode").html(da.account.muser.machineCode==null?"无":da.account.muser.machineCode);
					$("#parsentUserName").html(da.account.muser.parsentUserName==null?"无":da.account.muser.parsentUserName);
					$("#jiqi").attr("uty",da.account.muser.userType);
					$("#birthday").html(da.account.muser.birthday);
					if(da.account.muser.userName!=null){
                        var link = "https://wx.miduu.com/1.6.0zhuce_tiyan.html?id=" + da.account.muser.id;
                        $("#qrCodeContent").html(link);
					}
					$("#address").html(address);
					var qrCode="<img style='padding: 5px 5px 5px 5px;cursor:pointer;' alt='二维码无法显示' width='250px' height='250px' src='"+da.account.muser.qrCode+"'>";
					$("#qrCode").html(qrCode);
					if(da.account.muser.userType==2){
						$("#pbh").show();
						$("#pb").val(da.account.muser.profitability)
					}
					var avatarUrl = "<img style='padding: 5px 5px 5px 5px;cursor:pointer;' alt='头像未上传' width='250px' height='250px' src='"+da.account.muser.avatarUrl+"'>";
					
					
			/*		if(da.muser.machineQrCode!=null &&  da.muser.machineQrCode!=''){
						var machineQrCode="<img style='padding: 5px 5px 5px 5px;cursor:pointer;' alt='' width='250px' height='250px' src='"+da.muser.machineQrCode+"'>";
					   $('#machineQrCode').html(machineQrCode);
					}else{
						$("#jiqi").show();
					}*/
					 $('#avatarUrl').html(avatarUrl);
					
				}
			
			});
}





function getMachineQrCode(){
	 var userType=$("#jiqi").attr("uty");
	 if(userType!=4){
	 	alert("机器二维码只有百夫长及更高身份才能申请");
	 }
}


function updatePb(){
	var id=getvl("id");
	var profitability=$("#pb").val();
	var reg=/^0\.\d+$/;
	if(!reg.test(profitability)){
		alert("会员提成比例必须为小数");
		return;
	}
	if(confirm("您确定要修改该会员提成比例吗")){
		$.ajax({
			url: urlcore + "/api/muser/updatePb?id="+id+"&profitability="+profitability,
			type: "post",
			dataType: 'json',
			contentType: "application/json;charset=utf-8",
			data:{},
			success:function(data){
				alert("修改成功");
				window.location.reload();
			},
			error:function() {
				
			}
		});	
		
	}
		
	
	
}
